package cate.common.table.activity.throne;

import cate.common.table.ESheet;
import cate.common.util.random.RWItem;
import cate.common.util.random.RWList;
import easy.java.dev.note.NoteClass;

@NoteClass("选拔赛战斗奖励")
public class TBChallengeRwdSheet extends ESheet<TBChallengeRwdRow> {

    @Override
    public String getSheetName() {
        return "选拔赛战斗奖励";
    }

    private RWList<RR> successList = new RWList<>();
    private RWList<RR> failList = new RWList<>();

    public static class RR implements RWItem {

        public double weight;
        public int id;

        @Override
        public double getWeight() {
            return this.weight;
        }
    }

    @Override
    protected void onLoaded() {
        for (TBChallengeRwdRow row : list) {
            RR rr = new RR();
            rr.id = row.id;
            rr.weight = row.weight;
            if (row.success) {
                this.successList.add(rr);
            } else {
                this.failList.add(rr);
            }
        }
        this.successList.setup();
        this.failList.setup();
    }

    public String getReward(boolean success) {
        if (success) {
            return get(successList.get().id).rewardStr;
        } else {
            return get(failList.get().id).rewardStr;
        }
    }
}
